package com.剑指offer;

public class _51构建乘积数组
{
    public static void main(String[] args)
    {
        int []a = {1,2,3,4};
        int[] multiply = multiply(a);
        for (int i = 0; i < multiply.length; i++)
        {
            System.out.print(multiply[i] + " ");
        }
    }

    public static int[] multiply(int[] A) {
        int length = A.length;
        int B[] = new int[length];
        int sum = 1;
        if(length == 0)return A;
        for (int i = 0; i < length; i++)
        {
            for (int j = 0; j < length; j++)
            {
                if(i == j)continue;
                sum = sum * A[j];
            }
            B[i] = sum;
            sum = 1;
        }
        return B;
    }
}
